﻿/***********************************************************************************************
 * 
 * ProjectName: WMSSoft.Lib.Interfaces
 * 
 * Description: Provide the Interface to remove a File from Recent-List
 * 
 * Created:     30.08.2015
 * 
 * Author:      matthias wagler - matthias@WMSSoft.de
 * 
 * Copyright:   Copyright 2015 by WMSSoft.de
 * 
 * License:     GPLv3
 * 
 * History:     30.08.2015 - matthias wagler matthias@WMSSoft.de   -   Created
 * 
 **********************************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WMSSoft.Lib.Basic;
using WMSSoft.Lib.Enums;
using WMSSoft.Lib.Interfaces;
using WMSSoft.Lib.WinKStart;
using WMSSoft.Lib.Texte;

namespace WMSSoft.WinKStart.Functions
{
    public class RemoveRecent : iWinKStartFunctions
    {

        #region Interface Members
        /// <summary>
        /// Interface Member to Initialise the Function
        /// </summary>
        public void Init()
        {
            //Nothing TODO
        }

        /// <summary>
        /// Run the Code for this WinKStart Function
        /// </summary>
        /// <param name="DataSource">DataSource to work with Data from</param>
        /// <param name="Filter">Path to specify the Sub - Folder in DataSource</param>
        /// <param name="Data">Data from GUI to work with</param>
        /// <returns></returns>
        public bool Run(Dictionary<string, object> Data)
        {
            try
            {
                if (Data != null && Data.ContainsKey("ItemName") == true)
                {
                    if (System.IO.File.Exists((string)Data["ItemName"]) == true)
                    {
                        string sMessage = LanguageStrings.GetText(QuestionMessages.QUESTION_FUNCTION_RECENT_WORKER__DELETE_FILE, EStringTypes.stQuestion);
                        string sRecentFile = System.IO.Path.GetFileName((string)Data["ItemName"]);
                        sMessage = sMessage.Replace("###FILE###", sRecentFile);
                        if (System.Windows.MessageBox.Show(sMessage, 
                                                           LanguageStrings.GetText("Question"), 
                                                           System.Windows.MessageBoxButton.YesNo) == System.Windows.MessageBoxResult.Yes)
                        {
                            System.IO.File.Delete((string)Data["ItemName"]);
                        }

                    }
                    else
                    {
                        System.Windows.MessageBox.Show(LanguageStrings.GetText(InfoMessages.QUESTION_FUNCTION_RECENT_WORKER__FILE_DOESTNT_EXIST, EStringTypes.stMessage), 
                                                       LanguageStrings.GetText("Info"), System.Windows.MessageBoxButton.OK);
                    }
                    return true;
                }
                return false;
            }
            catch (Exception Ex)
            {
                throw new Exception("Error running Function!", Ex);
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public void Destroy()
        {
            //Nothing TODO
        }

        #endregion


    }


}
